use "$project_path/data/4_regdata/regdata", clear

** Appendix Figure E.4(a)

rdrobust diff_m1_chix_econ runvar_alt if treatment_alt!=., all
local rdd_rf_tau : di %8.3f e(tau_cl)
local rdd_rf_lb : di %8.3f e(ci_l_rb)
local rdd_rf_lb = subinstr("`rdd_rf_lb'", " ", "", .)
local rdd_rf_ub : di %8.3f e(ci_r_rb)
local rdd_rf_ub = subinstr("`rdd_rf_ub'", " ", "", .)
local rdd_rf_pval : di %8.3f e(pv_rb)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_rf_est = "Reduced form est.: `rdd_rf_tau' [`rdd_rf_lb', `rdd_rf_ub']. p-value: `rdd_rf_pval'. N = `N'"

rdrobust diff_m1_chix_econ runvar_alt if treatment_alt!=., fuzzy(treatment_alt) all
local rdd_fuzzy_tau : di %8.3f e(tau_cl)
local rdd_fuzzy_tau = subinstr("`rdd_fuzzy_tau'", " ", "", .)
local rdd_fuzzy_lb : di %8.3f e(ci_l_rb)
local rdd_fuzzy_lb = subinstr("`rdd_fuzzy_lb'", " ", "", .)
local rdd_fuzzy_ub : di %8.3f e(ci_r_rb)
local rdd_fuzzy_ub = subinstr("`rdd_fuzzy_ub'", " ", "", .)
local rdd_fuzzy_pval : di %8.3f e(pv_rb)
local rdd_fuzzy_pval = subinstr("`rdd_fuzzy_pval'", " ", "", .)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_fuzzy_est = "Fuzzy RD est.: `rdd_fuzzy_tau' [`rdd_fuzzy_lb', `rdd_fuzzy_ub']. p-value: `rdd_fuzzy_pval'"

rdplot diff_m1_chix_econ runvar_alt if inrange(runvar_alt, -20, 20), p(1) nbins(10 10) graph_options(xtitle("Margin of victory of the challenger", size(large)) ylabel(-.4(.2).6, angle(0) labsize(large)) graphregion(color(white)) note("`rd_rf_est'""`rd_fuzzy_est'", tstyle(size(medlarge))) xlabel(-20(5)20, labsize(large))  ytitle("Standard deviations", size(large)) legend(off) title("Economic performance", size(large)))
graph export "$project_path/output/appendix_figures/Appendix_Figure_E4a.pdf", as(pdf) name("Graph") replace

** Appendix Figure E.4(b)

rdrobust std_diff_m1_hdi runvar_alt if treatment_alt!=., all
local rdd_rf_tau : di %8.3f e(tau_cl)
local rdd_rf_lb : di %8.3f e(ci_l_rb)
local rdd_rf_lb = subinstr("`rdd_rf_lb'", " ", "", .)
local rdd_rf_ub : di %8.3f e(ci_r_rb)
local rdd_rf_ub = subinstr("`rdd_rf_ub'", " ", "", .)
local rdd_rf_pval : di %8.3f e(pv_rb)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_rf_est = "Reduced form est.: `rdd_rf_tau' [`rdd_rf_lb', `rdd_rf_ub']. p-value: `rdd_rf_pval'. N = `N'"

rdrobust std_diff_m1_hdi runvar_alt if treatment_alt!=., fuzzy(treatment_alt) all
local rdd_fuzzy_tau : di %8.3f e(tau_cl)
local rdd_fuzzy_tau = subinstr("`rdd_fuzzy_tau'", " ", "", .)
local rdd_fuzzy_lb : di %8.3f e(ci_l_rb)
local rdd_fuzzy_lb = subinstr("`rdd_fuzzy_lb'", " ", "", .)
local rdd_fuzzy_ub : di %8.3f e(ci_r_rb)
local rdd_fuzzy_ub = subinstr("`rdd_fuzzy_ub'", " ", "", .)
local rdd_fuzzy_pval : di %8.3f e(pv_rb)
local rdd_fuzzy_pval = subinstr("`rdd_fuzzy_pval'", " ", "", .)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_fuzzy_est = "Fuzzy RD est.: `rdd_fuzzy_tau' [`rdd_fuzzy_lb', `rdd_fuzzy_ub']. p-value: `rdd_fuzzy_pval'"

rdplot std_diff_m1_hdi runvar_alt if inrange(runvar_alt, -20, 20), p(1) nbins(10 10) graph_options(xtitle("Margin of victory of the challenger", size(large)) ylabel(-.4(.2).6, angle(0) labsize(large)) graphregion(color(white)) note("`rd_rf_est'""`rd_fuzzy_est'", tstyle(size(medlarge))) xlabel(-20(5)20, labsize(large))  ytitle("Standard deviations", size(large)) legend(off) title("Human Development Index", size(large)))
graph export "$project_path/output/appendix_figures/Appendix_Figure_E4b.pdf", as(pdf) name("Graph") replace

** Appendix Figure E.4(c)

rdrobust std_diff_m1_democracy_index runvar_alt if treatment_alt!=., all
local rdd_rf_tau : di %8.3f e(tau_cl)
local rdd_rf_lb : di %8.3f e(ci_l_rb)
local rdd_rf_lb = subinstr("`rdd_rf_lb'", " ", "", .)
local rdd_rf_ub : di %8.3f e(ci_r_rb)
local rdd_rf_ub = subinstr("`rdd_rf_ub'", " ", "", .)
local rdd_rf_pval : di %8.3f e(pv_rb)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_rf_est = "Reduced form est.: `rdd_rf_tau' [`rdd_rf_lb', `rdd_rf_ub']. p-value: `rdd_rf_pval'. N = `N'"

rdrobust std_diff_m1_democracy_index runvar_alt if treatment_alt!=., fuzzy(treatment_alt) all
local rdd_fuzzy_tau : di %8.3f e(tau_cl)
local rdd_fuzzy_tau = subinstr("`rdd_fuzzy_tau'", " ", "", .)
local rdd_fuzzy_lb : di %8.3f e(ci_l_rb)
local rdd_fuzzy_lb = subinstr("`rdd_fuzzy_lb'", " ", "", .)
local rdd_fuzzy_ub : di %8.3f e(ci_r_rb)
local rdd_fuzzy_ub = subinstr("`rdd_fuzzy_ub'", " ", "", .)
local rdd_fuzzy_pval : di %8.3f e(pv_rb)
local rdd_fuzzy_pval = subinstr("`rdd_fuzzy_pval'", " ", "", .)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_fuzzy_est = "Fuzzy RD est.: `rdd_fuzzy_tau' [`rdd_fuzzy_lb', `rdd_fuzzy_ub']. p-value: `rdd_fuzzy_pval'"

rdplot std_diff_m1_democracy_index runvar_alt if inrange(runvar_alt, -20, 20), p(1) nbins(10 10) graph_options(xtitle("Margin of victory of the challenger", size(large)) ylabel(-.4(.2).6, angle(0) labsize(large)) graphregion(color(white)) note("`rd_rf_est'""`rd_fuzzy_est'", tstyle(size(medlarge))) xlabel(-20(5)20, labsize(large))  ytitle("Standard deviations", size(large)) legend(off) title("Democracy", size(large)))
graph export "$project_path/output/appendix_figures/Appendix_Figure_E4c.pdf", as(pdf) name("Graph") replace

** Appendix Figure E.4(d)

rdrobust diff_m1_general_chix runvar_alt if treatment_alt!=., all
local rdd_rf_tau : di %8.3f e(tau_cl)
local rdd_rf_lb : di %8.3f e(ci_l_rb)
local rdd_rf_lb = subinstr("`rdd_rf_lb'", " ", "", .)
local rdd_rf_ub : di %8.3f e(ci_r_rb)
local rdd_rf_ub = subinstr("`rdd_rf_ub'", " ", "", .)
local rdd_rf_pval : di %8.3f e(pv_rb)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_rf_est = "Reduced form est.: `rdd_rf_tau' [`rdd_rf_lb', `rdd_rf_ub']. p-value: `rdd_rf_pval'. N = `N'"

rdrobust diff_m1_general_chix runvar_alt if treatment_alt!=., fuzzy(treatment_alt) all
local rdd_fuzzy_tau : di %8.3f e(tau_cl)
local rdd_fuzzy_tau = subinstr("`rdd_fuzzy_tau'", " ", "", .)
local rdd_fuzzy_lb : di %8.3f e(ci_l_rb)
local rdd_fuzzy_lb = subinstr("`rdd_fuzzy_lb'", " ", "", .)
local rdd_fuzzy_ub : di %8.3f e(ci_r_rb)
local rdd_fuzzy_ub = subinstr("`rdd_fuzzy_ub'", " ", "", .)
local rdd_fuzzy_pval : di %8.3f e(pv_rb)
local rdd_fuzzy_pval = subinstr("`rdd_fuzzy_pval'", " ", "", .)
if e(pv_rb)<0.001 local rdd_pval = "<0.001"
local N = e(N)
local rd_fuzzy_est = "Fuzzy RD est.: `rdd_fuzzy_tau' [`rdd_fuzzy_lb', `rdd_fuzzy_ub']. p-value: `rdd_fuzzy_pval'"

rdplot diff_m1_general_chix runvar_alt if inrange(runvar_alt, -20, 20), p(1) nbins(10 10) graph_options(xtitle("Margin of victory of the challenger", size(large)) ylabel(-.4(.2).6, angle(0) labsize(large)) graphregion(color(white)) note("`rd_rf_est'""`rd_fuzzy_est'", tstyle(size(medlarge))) xlabel(-20(5)20, labsize(large))  ytitle("Standard deviations", size(large)) legend(off) title("General index", size(large)))
graph export "$project_path/output/appendix_figures/Appendix_Figure_E4d.pdf", as(pdf) name("Graph") replace

